package com.zkca.xf.utils;

import android.graphics.Rect;
import android.support.v7.widget.RecyclerView;
import android.view.View;

/**
 * Created by xiaohua on 2017/10/16.
 */

public class SpaceItemDecoration extends RecyclerView.ItemDecoration {
    private int space;
    private boolean isNoHeader;

    public SpaceItemDecoration(int space) {
        this.space = space;
    }

    public SpaceItemDecoration(int space, boolean isNoHeader) {
        this.space = space;
        this.isNoHeader = isNoHeader;
    }

    @Override
    public void getItemOffsets(Rect outRect, View view, RecyclerView parent, RecyclerView.State state) {

        if (isNoHeader) {
                outRect.set(0, 0, 0, space);
        } else {
            if (parent.getChildAdapterPosition(view) > 1)
                outRect.set(0, 0, 0, space);
        }

    }
}
